<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>WS Echo Service Documentation</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0 2rem;
            background-color: #f5f5f5;
        }
        h1, h2 {
            color: #2c3e50;
        }
        pre {
            background-color: #ecf0f1;
            padding: 1rem;
            border-radius: 5px;
            overflow-x: auto;
        }
        code {
            font-family: Consolas, "Courier New", monospace;
            font-size: 1rem;
        }
        ul {
            line-height: 1.8;
        }
        .note {
            background-color: #e7f3fe;
            border-left: 6px solid #2196F3;
            margin: 1rem 0;
            padding: 0.5rem 1rem;
        }
        a {
            text-decoration: none;
            color: #2980b9;
            font-size: 1.2rem;
            font-weight: bold;
        }
        a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <a href="rest-services.html">REST Services Home Page</a>
    <h1>WS Echo Service Documentation</h1>
    <p>
        Welcome to the <strong>WS Echo Service</strong>. This service is designed to receive a text message from you 
        and send it back exactly as it was received. This type of service is often used to test connectivity 
        and ensure that web requests are correctly handled.
    </p>

    <div class="note">
        <strong>Note for Beginners:</strong> 
        This example shows how to make a request using both Burp Repeater (a popular testing tool) 
        and the <code>curl</code> command (a command-line tool for making web requests). If you’re new to web services, 
        don’t worry! Just follow along with the examples and you’ll get the hang of it quickly.
    </div>

    <h2>Endpoint</h2>
    <p>This is the address where the service is hosted:</p>
    <pre><code>POST /webservices/rest/ws-echo.php</code></pre>

    <h2>How It Works</h2>
    <p>The Echo Service expects a single parameter called <code>message</code> in the request. 
    It will return that same message in the response. This is useful to verify that your request 
    was successfully received and processed.</p>

    <h2>Request Parameters</h2>
    <ul>
        <li><b>message</b> (string, required): The message you want the server to send back.</li>
    </ul>

    <h2>Step-by-Step Example Using Burp Repeater</h2>
    <p>Here’s how you can send a request to this service using Burp Repeater:</p>
    <pre><code>POST /webservices/rest/ws-echo.php HTTP/1.1
Host: mutillidae.localhost
Accept: application/json
Content-Type: application/x-www-form-urlencoded
Origin: http://mutillidae.localhost
Connection: close
Content-Length: 20

message=Hello+World!</code></pre>

    <p><strong>Instructions:</strong></p>
    <ol>
        <li>Open Burp Suite and navigate to the Repeater tab.</li>
        <li>Copy the above request and paste it into the Repeater window.</li>
        <li>Click <strong>Send</strong> to see the response from the server.</li>
    </ol>

    <h2>Example Using <code>curl</code> (Command Line)</h2>
    <p>If you prefer using the command line, here’s how you can make the same request with <code>curl</code>:</p>
    <pre><code>curl -X POST "http://mutillidae.localhost/webservices/rest/ws-echo.php" \
 -H "Host: mutillidae.localhost" \
 -H "Accept: application/json" \
 -H "Origin: http://mutillidae.localhost" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 --data "message=Hello+World!"</code></pre>

    <p><strong>Instructions:</strong></p>
    <ol>
        <li>Open a terminal or command prompt.</li>
        <li>Copy and paste the above <code>curl</code> command.</li>
        <li>Press <strong>Enter</strong> to send the request and view the response.</li>
    </ol>

    <h2>Expected Response</h2>
    <p>If everything works correctly, you will receive a response like this:</p>
    <pre><code>{
    "message": "Hello World!",
    "command": "echo 'Hello World!'",
    "security-level": 0,
    "result": "Hello World!"
}</code></pre>

    <div class="note">
        <strong>Troubleshooting Tips:</strong> 
        If you encounter any issues:
        <ul>
            <li>Ensure that the <code>mutillidae.localhost</code> host is correctly configured in your environment.</li>
            <li>Check that the service is running and accessible.</li>
            <li>If using Burp Suite, make sure your browser or tool is correctly configured to route traffic to the webservice.</li>
        </ul>
    </div>

    <h2>Learn More</h2>
    <p>If you want to explore more, try modifying the <code>message</code> parameter and observe how the response changes. 
    For example, send the message <code>Hello from Class!</code> and see if the service returns the same.</p>
</body>
</html>

